package com.neusoft.controller;

import com.neusoft.entity.Employee;
import com.neusoft.service.EmployeeService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/employee")
@CrossOrigin
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    /**
     * 根据条件查询医生
     *
     * @param deptmentId    部门id
     * @param registLevelId 级别id
     * @param schedulingId  排班id
     * @return 医生列表
     */
    @RequestMapping("/queryEmpByCondition/{deptmentId}/{registLevelId}/{schedulingId}")
    public Result queryEmpByCondition(@PathVariable("deptmentId") int deptmentId,
                                      @PathVariable("registLevelId") int registLevelId,
                                      @PathVariable("schedulingId") int schedulingId) {
        return employeeService.queryEmpByCondition(deptmentId, registLevelId, schedulingId);
    }

    /**
     * 根据日程和部门查询医生列表
     *
     * @param deptmentId   部门id
     * @param schedulingId 日程id
     * @return 医生列表
     */
    @RequestMapping("/queryDocForCheck/{deptmentId}/{schedulingId}")
    public Result queryDocForCheck(@PathVariable("deptmentId") int deptmentId,
                                   @PathVariable("schedulingId") int schedulingId) {
        return employeeService.queryEmpByCondition(deptmentId, null, schedulingId);
    }

    /**
     * 根据医生id查询医生信息
     *
     * @param empId 医生id
     * @return 医生信息
     */
    @RequestMapping("/queryEmpById/{empId}")
    public Result queryEmpById(@PathVariable Integer empId) {
        return employeeService.queryEmpById(empId);
    }

    @RequestMapping("/userLogin")
    public Result empLogin(@RequestBody Employee employee) {
        //todo 实现用户登录功能
        return employeeService.userLogin(employee);
    }
}
